from django.test import TestCase

from asn.models import AsnDetailModel
from userprofile.models import Users

# Create your tests here.
class AsnTestCase(TestCase):

    def test_create(self):
        AsnDetailModel.objects.create(supplier='Supplier Name-10',goods_code='good002',goods_qty='150')
        AsnDetailModel.objects.create(supplier='Supplier Name-15',goods_code='good003',goods_qty='300')
        AsnDetailModel.objects.create(supplier='Supplier Name-19', goods_code='good001', goods_qty='300')
        Users.objects.create(user_id=1,name='cow11023')
        cls = AsnDetailModel.objects.get(supplier='Supplier Name-10')
        b1 = AsnDetailModel.objects.get(supplier='Supplier Name-15')
        b2 = AsnDetailModel.objects.get(supplier='Supplier Name-19')
        user1 = Users.objects.get(user_id=1)
        print("Models Testing And Login Check")
        print(user1.user_id)
        print(user1.name)
        print(cls.supplier)
        print(cls.goods_code)
        print(cls.goods_qty)
        print(b1.supplier)
        print(b1.goods_code)
        print(b1.goods_qty)
        print(b2.supplier)
        print(b2.goods_code)
        print(b2.goods_qty)
        self.assertEqual(cls.supplier,'Supplier Name-10')
        self.assertEqual(cls.goods_qty,150)

        def test_delete(self):
            cls = AsnDetailModel.objects.get(supplier='Supplier Name-10')
            cls.delete()
            result = AsnDetailModel.objects.filter(supplier='Supplier Name-10')
            self.assertEqual(len(result),0)

    # def test_suppliername_null(self):
    #     response = self.client.post('/asn/detail/',data=self.addCleanup())